<!DOCTYPE html>
<html style="height: 100%">
   <head>
       <meta charset="utf-8">
   </head>
   <body style="height: 100%; margin: 0" >
       <div id="container" style="height: 100%"></div>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts-all-3.js"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts-stat/ecStat.min.js"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/dataTool.min.js"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/world.js"></script>
       <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ZUONbpqGBsYGXNIYHicvbAbM"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/bmap.min.js"></script>
       <script type="text/javascript">
        var MyCharts;
       function draw(){
          var dom = document.getElementById("container");
          var myChart = echarts.init(dom);
          var app = {};
          option = null;
          option = {
              
              tooltip: {
                  trigger: 'axis'
              },
              legend: {
                  data:['数据一','数据二']
              },
            
              xAxis: {
                  type: 'category',
                  boundaryGap: false,
                  data: ['01','02','03','04','05','06','07']
              },
              yAxis: {
                  type: 'value'
              },
              series: [{
                  name: '委案金额',
                  type: 'line',
                  smooth: true,
                  // data: [1000, 120, 210, 540, 2600, 830, 710]
                  data:(function (){
                         var res = [];
                         // var len = 7;
                         // while (len--) {
                         //      res.push(Math.round(Math.random() * 1000));
                         //  }
                         for(var i=0;i<7;i++){
                           res.push(Math.round(Math.random() * 1000));
                         }
                          return res;
                  })()
              },
              {
                  name: '还款金额',
                  type: 'line',
                  smooth: true,
                  // data: [300, 1820, 434, 791, 3900, 300, 100]
                  data:(function (){
                         var res = [];
                         
                         for(var i=0;i<7;i++){
                           res.push(Math.round(Math.random() * 1000));
                         }
                          return res;
                  })()
              },
           
              ]
          };


          if (option && typeof option === "object") {
             MyCharts = myChart.setOption(option, true);
          }

                 }
       draw();
setInterval(function (){
    draw();
    var data0 = option.series[0].data;
    var data1 = option.series[1].data;
    // data0.shift();
    data0.push(Math.round(Math.random() * 1000));
    // data1.shift();
    data1.push(Math.round(Math.random() * 1000));

     MyCharts;

 }, 2000);

       </script>
   </body>
</html> 